package com.ideaaedi.springcloud.jd.commonspring.config;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * fastjson2全局配置
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2021.0.1.C
 */
@Configuration
public class FastJsonConfig {
    
    @PostConstruct
    public void doGlobalConfig() {
        // 以name形式序列化枚举 (fastjson1默认即为开启)
        JSON.config(JSONWriter.Feature.WriteEnumsUsingName);
        // 反序列化时，支持智能匹配 (fastjson1默认即为开启)
        JSON.config(JSONReader.Feature.SupportSmartMatch);
    }
}
